{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Document { location: [Getter/Setter] }"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "var jsdom = require('jsdom');\n",
    "const { JSDOM } = jsdom;\n",
    "const { document } = (new JSDOM('')).window;\n",
    "global.document = document;\n",
    "var d3 = require(\"d3\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 理解Update、Enter、Exit\n",
    "\n",
    "`update`和`enter`：例如将数组`[3,6,9,12,15]`绑定到三个`<p>`上。可以想象到，数组的最后两个元素没有可以绑定的元素，这时D3会建立两个空的元素与数组最后的两个数据相对于，那么这部分就称为**Enter**。而有元素与数据对应的部分就称为**Update**。\n",
    "exit：如果数组`[3]`绑定到三个<p>上，可以想象，最后两个`<p>`没有可绑定的数据，那么没有数据绑定的部分就称为**Exit**。"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAk8AAAFGCAYAAABzIHs7AAAgAElEQVR4Ae2diZGjMBBFicsBOR5H42QmGKYENIhbJ3Tjp6ot2SCk30/XN8azTUuCAAQgAAEIQAACEAgm0ASXpCAEIAABCEAAAhCAQIt5YhBAAAIQgAAEIACBCAKYpwhYFIUABCAAAQhAAAKYJ8YABCAAAQhAAAIQiCCAeYqARVEIQAACEIAABCCAeWIMQAACEIAABCAAgQgCmKcIWBSFAAQgAAEIQAACmCfGAAQgAAEIQAACEIgggHmKgEVRCEAAAhCAAAQggHliDEAAAhCAAAQgAIEIApinCFgUhQAEIAABCEAAApgnxgAEIAABCEAAAhCIIIB5ioBFUQhAAAIQgAAEIIB5YgxAAAIQgAAEIACBCAIVzNNf+3k1bfP+RshQUPTv075en/ZPgRQkQAACTyLAmvik3iQWCDgCmKdhHHzfTdtgnpgVEIBAcQI2zRNrYvGBQIUPIoB5GjqTheJBo5pQIKC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EME+bWDgIAQhAAAIQgAAEtgn8A1KvSXoyzHjOAAAAAElFTkSuQmCC"
    }
   },
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![image.png](attachment:image.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {},
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d3.select(document.body).append('p')\n",
    "d3.select(document.body).append('p')\n",
    "d3.select(document.body).append('p')\n",
    "\n",
    "var dataset = [3, 6, 9, 12, 15];\n",
    "var p = d3.select(\"body\")\n",
    "    .selectAll(\"p\");\n",
    "var update = p.data(dataset) //绑定数据,并得到update部分\n",
    "var enter = update.enter(); //得到enter部分\n",
    "//下面检验是否真的得到对于update的处理\n",
    "update.text(function(d, i) {\n",
    "    return \"update: \" + d + \",index: \" + i;\n",
    "})\n",
    "//对于enter的处理\n",
    "//注意，这里需要先添加足够多的<p>，然后在添加文本\n",
    "var pEnter = enter.append(\"p\") //添加足够多的<p>\n",
    "pEnter.text(function(d, i) {\n",
    "            return \"enter: \" + d + \",index: \" + i;\n",
    "        })\n",
    "$$.html(document.body.innerhtml)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Selection {\n",
       "  _groups: [\n",
       "    [\n",
       "      <1 empty item>,\n",
       "      [HTMLParagraphElement],\n",
       "      [HTMLParagraphElement],\n",
       "      [HTMLParagraphElement],\n",
       "      [HTMLParagraphElement]\n",
       "    ]\n",
       "  ],\n",
       "  _parents: [ HTMLBodyElement {} ]\n",
       "}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "var dataset = [ 3 ];\n",
    "\n",
    "//选择body中的p元素\n",
    "var p = d3.select(\"body\").selectAll(\"p\");\n",
    "\n",
    "//获取update部分\n",
    "var update = p.data(dataset);\n",
    "\n",
    "//获取exit部分\n",
    "var exit = update.exit();\n",
    "\n",
    "//update部分的处理：更新属性值\n",
    "update.text(function(d){\n",
    "    return \"update \" + d;\n",
    "});\n",
    "\n",
    "//exit部分的处理：修改p元素的属性\n",
    "exit.text(function(d){\n",
    "        return \"exit\";\n",
    "    });\n",
    "\n",
    "//exit部分的处理通常是删除元素\n",
    "\n",
    "exit.remove();"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Javascript (Node.js)",
   "language": "javascript",
   "name": "javascript"
  },
  "language_info": {
   "file_extension": ".js",
   "mimetype": "application/javascript",
   "name": "javascript",
   "version": "13.13.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
